<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/js/flatpickr.min.css" />
		<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css" />
		<link rel="stylesheet" type="text/css" href="/css/font-awesome.css" />
	</head>

	<body>
		<!--顶部导航 -->
		<nav class="topNavItemBox">
			<div id="ItemBox">
				<div class="title">肉品溯源管理系统</div>
			</div>
		</nav>
		<!-- 左侧导航 -->
		<#include "left.ftl"/>

        <!--供应商管理-->
		<div class="page_main">
			<h3>供应商管理</h3><span class="add_link"><a href="supplierAdd.ftl">新增信息></a></span>
			<div class="page_content">
				<h4>供应商查询</h4>
				<br /><br />
				<form id="supplier_query" method="post" action="CompanyAction_getCompanyBycondiction">
					<label style="width:100px">供应商ID</label><input type="text" name="compID" class="commonInputtext" /><span></span>
				    <label style="width:120px">供应商名称</label><input type="text" name="name" class="commonInputtext" /><span></span>
					<label style="width:120px">供应商类型</label>
					<span><input type="radio" name="bussiness" value="疫苗"/>疫苗</span>
					<span><input type="radio" name="bussiness" value="饲料" />饲料</span>
					<input type="submit" value="查询"  style="display: inline-block; margin-left: 30px;" />
					<br />

				</form>
				<div>
					<table id="supplier_table" class="table" width="100%">
						<thead>
							<tr>
								<th width="30"></th>
								<th width="150">企业编号</th>
								<th width="150">企业名称</th>
								<th width="150">经营范围 </th>
								<th width="150">法人</th>
								<!-- 			<th width="120">经手人</th> -->
								<th width="150">联系人 </th>
								<th width="150">联系人电话</th>
								<th width="200">联系人传真</th>
								<th width="200">投诉电话</th>
								<th width="80"></th>
							</tr>
						</thead>
						<tbody>
							<tr id="no_data">
								<td></td>
								<td>暂无数据</td>

							</tr>
						</tbody>
					</table>
				</div>
				<div id="barcon" name="barcon" style="margin-left: 200px;font-size:10px"></div>
				<!--<input type="button" id="deleteAllchoice" value="删除所选">-->
			</div>
			<div class="footer">
				<div class="footer_lineone">
					<span id="logo"></span>肉品溯源管理系统 
					<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
					<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
					<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
				</div>
				<div class="footer_linetwo">
					 &copy;2017广东技术师范学院
				</div>
			</div>
		</div>

		<script src="/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/jquery.form.js"></script>
		<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
		<script src="/dialog/js/dialog.js"></script>
		<script src="/js/flatpickr.js"></script>
		<script src="/js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="UTF-8">
			$(function() {
				//侧边栏初始化
				$(".vertical-nav").verticalnav({
					speed: 400,
					align: "left"
				});

				//时间控制初始化

				var re_data; //每次传过来的数据

				//查询
				$("#supplier_query").ajaxForm(function(data) {
					console.log(data);
					re_data = data;
			
					//去除暂无数据
					$("#supplier_table tbody tr").remove();
					for(var i = 0; i < data.length; i++) {
						var no = i+1;
						var tb = $("#supplier_table tbody");
						var td1 = '<td>' + no + '</td>';
						var td2 = '<td>' + data[i].gid + '</td>';
						var td3 = '<td>' + data[i].compName + '</td>';
						var td4 = '<td>' + data[i].business + '</td>';
						var td5 = '<td>' + data[i].legalPname + '</td>';
						var td6 = '<td>' + data[i].contacts + '</td>';
						var td7 = '<td>' + data[i].contactsPhone + '</td>';
						var td8 = '<td>' + data[i].contactsFax + '</td>';
						var td9 = '<td>' + data[i].complaintPhone + '</td>';
						var td10 = '<td><input type="button" onclick="moreInfo(' + i + ')" value="更多信息" ></td>';
						var td_last = '<td><input type="button" onclick="updateData(' + i + ')" class="change" value="更改" style="padding:0 5px"/>'
						var tr_add = '<tr id="supplier_row' + data[i].gid + '">' + td1 + td2 + td3 + td4 + td5 +td6 + td7 + td8 + td9 + td10 + td_last + '</tr>'
						tb.append(tr_add);
					}
					$("#no_data").remove();
					goPage(1,4,"supplier_table");
				});

				//更多信息
				 moreInfo = function(i) {
					var diaRow1 = '<div style="width:500px"><label class="dialog_label">企业编号</label><span>' + re_data[i].gid + '</span></div>';
					var diaRow2 = '<div><label class="dialog_label">企业类型编码</label><span>' + re_data[i].compTypeCode.compTypeId + '</span></div>';
					var diaRow3 = '<div><label class="dialog_label">企业名称</label><span>' + re_data[i].compName + '</span></div>';
					var diaRow4 = '<div><label class="dialog_label">企业机构编码</label><span>' + re_data[i].compCode + '</span></div>';
					var diaRow5 = '<div><label class="dialog_label">成立日期</label><span>' + re_data[i].foundedTime.slice(0,10)+ '</span></div>';
					var diaRow6 = '<div><label class="dialog_label">注册地址</label><span>' + re_data[i].regAddr + '</span></div>';
					var diaRow7 = '<div><label class="dialog_label">注册资金</label><span>' + re_data[i].capital + '</span></div>';
					var diaRow8 = '<div><label class="dialog_label">经营范围</label><span>' + re_data[i].business + '</span></div>';
					var diaRow9 = '<div><label class="dialog_label">法人</label><span>' + re_data[i].legalPname + '</span></div>';
					var diaRow10 = '<div><label class="dialog_label">联系人</label><span>' + re_data[i].contacts + '</span></div>';
					var diaRow11 = '<div><label class="dialog_label">联系人电话</label><span>' + re_data[i].contactsPhone + '</span></div>';
					var diaRow12 = '<div><label class="dialog_label">传真</label><span>' + re_data[i].contactsFax + '</span></div>';
					var diaRow13 = '<div><label class="dialog_label">投诉电话</label><span>' + re_data[i].complaintPhone + '</span></div>';
					var diaRow14 = '<div><label class="dialog_label">企业等级</label><span>' + re_data[i].companyLevel+ '</span></div>';
					var diaRow15 = '<div><label class="dialog_label">企业资质</label><span>' + re_data[i].companyCert + '</span></div>';
					var diaRow16 = '<div><label class="dialog_label">备注</label><span >' + re_data[i].remark + '</span></div>';
	
					var dia_add = diaRow1 + diaRow2 + diaRow3 + diaRow4 + diaRow5 + diaRow6 + diaRow7 + diaRow8 + diaRow9 + diaRow10 + diaRow11 + diaRow12 + diaRow13 +diaRow14 + diaRow15 + diaRow16;
					$.dialog({
						contentHtml: dia_add
					});
				}

				//更新
				updateData = function(i) {
					var row0 = '<form id="supplier_updateform" action="CompanyAction_updateCompany" method="post">'
					var row1 = '<li><label class="labelBeforinput">企业编号</label><input name="gid" class="bigInputtext" type="text" readonly="true" value="' + re_data[i].gid + '" /></li>';
					var row2 = '<li><label class="labelBeforinput">企业类型编码</label><input name="compTypeCode.compTypeId" class="bigInputtext" type="text" readonly="true" value="' + re_data[i].compTypeCode.compTypeId + '" /></li>';
					var row3 = '<li><label class="labelBeforinput">企业名称</label><input name="compName" class="bigInputtext" type="text" value="' + re_data[i].compName + '" /></li>';
					//var row4 = '<li><label class="labelBeforinput">企业机构编码</label><input name="compCode" class="bigInputtext" type="text" value="' + re_data[i].compCode + '" /></li>';
					var row5 = '<li><label class="labelBeforinput">成立日期</label><input name="foundedTime" data-date-format="Y-m-d" class="bigInputtext" type="text" value="' + re_data[i].foundedTime.slice(0,10) + '" /></li>';
					var row6 = '<li><label class="labelBeforinput">注册地址</label><input name="regAddr"  class="bigInputtext" type="text" value="' + re_data[i].regAddr + '" /></li>';
					//var row7 = '<li><label class="labelBeforinput">注册资金</label><input name="capital" class="bigInputtext" type="text" value="' + re_data[i].capital + '" /></li>';
					var row8 = '<li><label class="labelBeforinput">经营范围</label><input name="business" class="bigInputtext" type="text" value="' + re_data[i].business + '" /></li>';
					var row9 = '<li><label class="labelBeforinput">法人</label><input name="legalPname" class="bigInputtext" type="text" value="' + re_data[i].legalPname + '" /></li>';
					var row10 = '<li><label class="labelBeforinput">联系人</label><input name="contacts" class="bigInputtext" type="text" value="' + re_data[i].contacts + '" /></li>';
					var row11 = '<li><label class="labelBeforinput">联系人电话</label><input name="contactsPhone" class="bigInputtext" type="text" value="' + re_data[i].contactsPhone + '" /></li>';
					var row12 = '<li><label class="labelBeforinput">传真</label><input name="contactsFax" class="bigInputtext" type="text" value="' + re_data[i].contactsFax + '" /></li>';
					var row13 = '<li><label class="labelBeforinput">投诉电话</label><input name="complaintPhone" class="bigInputtext" type="text" value="' + re_data[i].complaintPhone + '" /></li>';
					var row14 = '<li><label class="labelBeforinput">企业等级</label><input name="companyLevel" class="bigInputtext" type="text" value="' + re_data[i].companyLevel + '" /></li>';
					var row15 = '<li><label class="labelBeforinput">企业资质</label><input name="companyCert" class="bigInputtext" type="text" value="' + re_data[i].companyCert + '" /></li>';
					var row16 = '<li><label class="labelBeforinput">备注</label><input name="remark" class="bigInputtext" type="text" value="' + re_data[i].remark + '" /></li>';
					var row17 = '<input name="legalCode" class="bigInputtext" type="hidden" value="' + re_data[i].legalCode + '" />';
					
					var row18 = '</form>'
					var str = row0 + row1 + row2 + row3 + row5 + row6 + row8 + row9 + row10 + row11 + row12 + row13 + row14 + row15 + row16 + row17+ row18;
					//console.log($("#quarantine_table"));

					//弹窗
					$.dialog({
						type: 'confirm',
						titleText: '更改数据',
						contentHtml: str,
						onClickOk: function() {
							$("#supplier_updateform").ajaxSubmit({
								type: 'post',
								success: function(data) {
								
									console.log(data);
									//回显
									
									var row = $("#supplier_row" + data.data.gid);
									row.find("td").eq(1).text(data.data.gid);
									row.find("td").eq(2).text(data.data.compName);
									row.find("td").eq(3).text(data.data.business);
									row.find("td").eq(4).text(data.data.legalPname);
									row.find("td").eq(5).text(data.data.contacts);
									row.find("td").eq(6).text(data.data.contactsPhone);
									row.find("td").eq(7).text(data.data.contactsFax);
									row.find("td").eq(8).text(data.data.complaintPhone);
									
									re_data[i]=data.data;
								}
							});
						}
					});

					//时间控制器

					
				}
			})
		</script>

	</body>

</html>